<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\modules\Admin\models\User */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="user-form">

     <?php $form = ActiveForm::begin([
             'options' => ['enctype' => 'multipart/form-data'],
             'layout' => 'horizontal',
             'fieldConfig' => [
                'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
                'horizontalCssClasses' => [
                    'label' => 'col-sm-2',
                    'wrapper' => 'col-sm-7',
                    'error' => '',
                ],
             ],
        ]); ?>

    <?= $form->field($model, 'schoolid')->textInput() ?>

    <?= $form->field($model, 'name')->textInput() ?>

    <?= $form->field($model, 'pinyin')->textInput() ?>

    <?= $form->field($model, 'age')->textInput() ?>

    <?= $form->field($model, 'password')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'sex')->inline(true)->radioList(\yii::$app->params['sex'])?>

    <?= $form->field($model, 'classname')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'sign')->textArea(['maxlength' => true]) ?>

    <div class="form-group text-center">
        <?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">

$("#user-name").change(function(){
    var name = $(this).val(); 

    $.get("/admin/user/pinyin", {name:name}, function(data){
        if(data){
            $("#user-pinyin").val(data);
        }else{
            $("#user-pinyin").val('');
        }
    });
});


</script>
<?php app\components\JsBlock::end() ?>
